package com.zy.mc_module.mvp.model;

import com.zy.mc_module.mvp.bean.BaseBean;
import com.zy.mc_module.mvp.contract.SetPwdContract.Model;
import com.zy.mc_module.utils.MD5;
import com.zy.mc_module.utils.UserUtils;
import com.zy.mc_module.utils.retrofit.RetrofitManager;
import io.reactivex.Observable;
import okhttp3.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created on 18/12/1
 */
public class SetPwdModel implements Model {
    @Override
    public Observable<ResponseBody> setPwd(Object... objects) {
        Map<String, Object> map = new HashMap<>();
        map.put("phone", objects[0]);
        map.put("code", objects[1]);
        map.put("password", MD5.md5((String) objects[2]));
        map.put("inviteUserCode", objects[3]);
        map.put("openid", objects[4]);
        map.put("uuid", objects[5]);
        map.put("nickname", objects[6]);
        map.put("headimgurl", objects[7]);
        map.put("repassword", MD5.md5((String) objects[8]));
        map.put("userName", objects[9]);
        return RetrofitManager.getInstance().getApi().register(map);
    }

    @Override
    public Observable<BaseBean<Boolean>> H5SetPassword(Object... objects) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", UserUtils.getUid());
        map.put("passWord", MD5.md5((String) objects[0]));
        map.put("userName", objects[1]);
        return RetrofitManager.getInstance().getApi().H5SetPassword(map);
    }
}
